package leetcode;

public class CountEven {
    public static void main(String[] args) {
        CountEven countEven = new CountEven();
        System.out.println(countEven.countEven(4));
    }

    public int countEven(int num) {
        int ans = 0;
        for (int i = 1; i <= num; i++) {
            int temp = i;
            int sum = 0;
            while (temp >= 1) {
                sum += temp % 10;
                temp /= 10;
            }
            if (sum % 2 == 0) {
                ans++;
            }
        }
        return ans;
    }
}
